<template>
	<view class="u-demo" style="margin-top: 30upx;">
		<view class="u-demo-wrap">
			<view class="u-demo-area">
				<u-steps :direction="direction" :current="current" :list="steps" :mode="mode" :icon="icon"></u-steps>
			</view>
		</view>
		<view class="wrap" v-show="current===0" style="margin-left: 30upx;">
			<u-form :model="model" :rules="rules" ref="uForm" :errorType="errorType">
				<u-form-item :rightIconStyle="{color: '#888', fontSize: '32rpx'}" :label-position="labelPosition"
					label="标题" label-width="150">
					<u-input :border="border" placeholder="标题" v-model="title" type="text"></u-input>
				</u-form-item>
				<u-form-item :rightIconStyle="{color: '#888', fontSize: '32rpx'}" :label-position="labelPosition"
					label="报警类别" label-width="150">
					<u-input :border="border" placeholder="报警类别" v-model="value" type="text" disabled="disabled">
					</u-input>
				</u-form-item>
				<u-form-item label="报警内容">
					<bgyxedit @bgyxchange="getInfo" :showdone="true" uploadurl="http://121.41.88.175:8080/common/upload">
					</bgyxedit>
				</u-form-item>
				<u-form-item :rightIconStyle="{color: '#888', fontSize: '32rpx'}" :label-position="labelPosition"
					label="报警地点" label-width="150">
					<u-input :border="border" placeholder="报警地点" v-model="position" type="text"></u-input>
				</u-form-item>
			</u-form>
		</view>
		<u-row gutter="16" style="margin-top: -10upx;">
			<u-col span="6" text-align="center">
				<u-button @click="submit1">提交</u-button>
			</u-col>
		</u-row>
		<u-toast ref="uToast" />
	</view>
	</view>
</template>

<script>
	import bgyxedit from "@/pages/compoents/bgyxedit/bgyxedit.vue"
	export default {
		components: {
			bgyxedit
		},
		data() {
			return {
				//下拉
				array: [],
				list1: [],
				index: 0,
				show: true, //模态框
				action: undefined,
				fileList: [],
				type: 0,
				steps: [{
					name: '填写报警信息'
				}],
				current: 0,
				icon: 'checkmark',
				mode: 'number',
				direction: 'row',
				model: {},
				rules: {},
				border: false,
				check: false,
				selectStatus: 'close',
				actionSheetShow: false,
				pickerShow: false,
				selectShow: false,
				radioCheckWidth: 'auto',
				radioCheckWrap: false,
				labelPosition: 'left',
				codeTips: '',
				errorType: ['message'],
				value: '',
				type:'',
				position:'',
				content:'',
				title:'',
				}
		},

		onLoad: function(e) {
			this.value = (e.id);
			this.type = (e.type);
		},

		methods: {
			submit1() {
				let data= {
					createUser:uni.getStorageSync('Id'),
					title :this.title,
					type:this.type,
					content:this.content,
					createPosition:this.position,
				};
				this.axios.post("http://localhost:8080/front/alarm/insert?createUser=" + data.createUser + "&title=" + data.title + "&content="+data.content + "&createPosition="+ data.createPosition+"&type="+data.type
				).then((res) => {
					console.log(res.data)
					if (res.status === 200) {
						// window.sessionStorage.setItem('userId', res.data.data.userId)
						uni.reLaunch({
							url: '../home/first'
						})
					}
					//if(res.)
				})
			},

			getContent() {
				console.log(this.content)
			},
			
			getInfo(e) {
				this.content = e.html;
			}
		}
	}
</script>

<style lang="scss" scoped>

</style>
